<template>
  <div class="box">
    <div>{{obj.a}}</div>
    <button @click="onChange">change</button>
  </div>

</template>
<script setup lang="ts">
import { ref, watch } from 'vue';


let obj = ref({});
watch(obj.value, (newVal) => {
  console.log(newVal);

})

const onChange = () => {
  if (!obj.value.a) {
    obj.value.a = 1;
  } else {
    obj.value.a++;
  }


}
</script>
<style scoped lang="scss">
.box {
  margin-top: 50px;
}
</style>